package com.fms.model.factory;

import java.util.Calendar;

import junit.framework.TestCase;

import org.jmock.Expectations;
import org.jmock.Mockery;

import com.fms.model.domain.FlowSheet;
import com.fms.model.factory.parts.IDateSelector;
import com.fms.model.factory.parts.IFileNameSupplier;

public class GeneralFactoryTest extends TestCase
{
	Mockery mock;
	public void setUp()
	{
		mock = new Mockery();
		
	}
	
	public void tearDown()
	{
		mock.assertIsSatisfied();
	}
	
	
	public void testCheckCorrectConstruction()
	{
		final IFileNameSupplier s = mock.mock(IFileNameSupplier.class);
		final IDateSelector d = mock.mock(IDateSelector.class);
		
		final Calendar c = Calendar.getInstance();
		
		
		GeneralFactory f = new GeneralFactory(s, d);
		
		mock.checking(new Expectations()
		{{
			oneOf(s).getFile(); will(returnValue("FileNAME!"));
			oneOf(d).getTime(); will(returnValue(c));
		}});
		
		
		FlowSheet fs = f.newSheet();
		
		assertTrue(fs.getFileName().equals("FileNAME!"));
		assertTrue(fs.getDate().equals(c));
	}
}
